package com.ruoyi.web.controller.huiyuan;

import java.util.List;

import com.ruoyi.system.service.ICcgmhyfyService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Ccgmhyfy;
import com.ruoyi.framework.web.base.BaseController;
import com.ruoyi.common.page.TableDataInfo;
import com.ruoyi.common.base.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 初次购买会员费用 信息操作处理
 * 
 * @author ruoyi
 * @date 2019-07-16
 */
@Controller
@RequestMapping("/system/ccgmhyfy")
public class CcgmhyfyController extends BaseController
{
    private String prefix = "system/ccgmhyfy";
	
	@Autowired
	private ICcgmhyfyService ccgmhyfyService;
	
	@RequiresPermissions("system:ccgmhyfy:view")
	@GetMapping()
	public String ccgmhyfy()
	{
	    return prefix + "/ccgmhyfy";
	}
	
	/**
	 * 查询初次购买会员费用列表
	 */
	@RequiresPermissions("system:ccgmhyfy:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(Ccgmhyfy ccgmhyfy)
	{
		startPage();
        List<Ccgmhyfy> list = ccgmhyfyService.selectCcgmhyfyList(ccgmhyfy);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出初次购买会员费用列表
	 */
	@RequiresPermissions("system:ccgmhyfy:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(Ccgmhyfy ccgmhyfy)
    {
    	List<Ccgmhyfy> list = ccgmhyfyService.selectCcgmhyfyList(ccgmhyfy);
        ExcelUtil<Ccgmhyfy> util = new ExcelUtil<Ccgmhyfy>(Ccgmhyfy.class);
        return util.exportExcel(list, "ccgmhyfy");
    }
	
	/**
	 * 新增初次购买会员费用
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存初次购买会员费用
	 */
	@RequiresPermissions("system:ccgmhyfy:add")
	@Log(title = "初次购买会员费用", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(Ccgmhyfy ccgmhyfy)
	{		
		return toAjax(ccgmhyfyService.insertCcgmhyfy(ccgmhyfy));
	}

	/**
	 * 修改初次购买会员费用
	 */
	@GetMapping("/edit/{ccgmhyfy}")
	public String edit(@PathVariable("ccgmhyfy") Integer ccgmhyfyId, ModelMap mmap)
	{
		Ccgmhyfy ccgmhyfy = ccgmhyfyService.selectCcgmhyfyById(ccgmhyfyId);
		mmap.put("ccgmhyfy", ccgmhyfy);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存初次购买会员费用
	 */
	@RequiresPermissions("system:ccgmhyfy:edit")
	@Log(title = "初次购买会员费用", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(Ccgmhyfy ccgmhyfy)
	{		
		return toAjax(ccgmhyfyService.updateCcgmhyfy(ccgmhyfy));
	}
	
	/**
	 * 删除初次购买会员费用
	 */
	@RequiresPermissions("system:ccgmhyfy:remove")
	@Log(title = "初次购买会员费用", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{

		return toAjax(ccgmhyfyService.deleteCcgmhyfyByIds(ids));
	}
	
}
